package com.powernobug.service.impl;

import com.powernobug.bean.vo.data.EChartData;
import com.powernobug.mapper.MarketStatMapper;
import com.powernobug.service.StatService;
import com.powernobug.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;
import java.util.Map;
import java.util.Set;

public class StatServiceImpl implements StatService {
    @Override
    public EChartData userStat() {
        try (SqlSession sqlSession = MyBatisUtil.getSqlSession()){
            MarketStatMapper statMapper = sqlSession.getMapper(MarketStatMapper.class);
            List<Map<String,Object>> rows = statMapper.userStat();
            Map<String, Object> map = rows.get(0);
            Set<String> columns = map.keySet();
            EChartData data = new EChartData(columns, rows);
            return data;
        }

    }
}
